package java_0385_codeblock;

import javax.xml.stream.events.DTD;

public class CodeBlock01 {
    public static void main(String[] args) {
        Movie 哪吒 = new Movie("哪吒");
        System.out.println("==========================");
        Movie movie = new Movie("唐探3", 100, "陈思诚");
    }


}

class Movie{
    private String name;
    private double price;
    private String director;

    //3个构造器-》重载
    //(1)下面的三个构造器都有相同的语句,这样代码看起来比较冗余
    //(2)这时我们可以把相同的语句，放到一个代码块中即可
    //(3)不管调用哪个构造器创建对象，都会先调用代码块的内容
    //(4)代码块的调用顺序优先于构造器。。
    {
        System.out.println("电影屏幕打开。。。");
        System.out.println("广告开始。。。");
        System.out.println("电影正式开始。。。");

    }

    public Movie(String name) {
        this.name = name;
        System.out.println(name);
    }

    public Movie(String name, double price) {
        this.name = name;
        this.price = price;
    }

    public Movie(String name, double price, String director) {
        this.name = name;
        this.price = price;
        this.director = director;
        System.out.println(name+" "+price+" "+director);
    }
}
